Skip to content

[fix](rbo) Preserve semantics in predicate inference - #67919

Merged
morrySnow merged 13 commits into
apache:masterfrom
feiniaofeiafei:codex/fix-predicate-inference-semantics
Sep 23, 2026
Merged

morrySnow merged 13 commits into
apache:masterfrom
feiniaofeiafei:codex/fix-predicate-inference-semantics

Conversation

@feiniaofeiafei

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Problem Summary:

Fix two predicate inference errors that change query results:

  • chooseInputPredicates records a retained GT/GTE predicate as EQ. The false equality can make another necessary predicate appear redundant. For example, a > b AND rn > b AND a > rn can lose a > rn and return extra rows in a QUALIFY query. Record the actual relation in the working graph.
  • Comparison-equal operands are not interchangeable inside arbitrary expressions. DATE and DATETIME values can compare equal but have different string lengths; negative and positive floating-point zero compare equal but have different SIGNBIT results. Substitution can therefore add filters that discard matching rows. Restrict expression substitution to exactly matching supported scalar types with value-preserving equality. Preserve direct comparisons, IN and their negations on the unwrapped operand, along with the existing determinism and cast-analysis checks.

The fixes are in separate commits. Shared cast extraction is unchanged, and existing regression expectations are unchanged.

Release note

Fix extra or missing rows caused by incorrect predicate inference, including QUALIFY inequality chains and substitutions inside type-sensitive or representation-sensitive expressions.

Check List (For Author)

  • Test:
    • Regression test: all six suites passed: infer_predicate_qualify, infer_predicate_replace_type, infer_unequal_predicates, extend_infer_equal_predicate, infer_predicate, and infer_datetimev2_cast_precision. New expected files were generated by the regression runner and verified by rerunning the suites.
    • Unit Test: all 65 tests in UnequalPredicateInferTest and InferPredicateByReplaceTest passed. New inequality checks cover 234 relation/order/qualifier combinations with 64 value assignments per combination. Substitution tests cover type/precision boundaries, signed zero, safe same-type substitutions, widening casts, and direct comparison/IN/NOT IN propagation.
    • Manual test: reproduced extra QUALIFY rows and missing DATE/signed-zero rows before deployment; the rebuilt FE returned the expected results. Verified the deployed FE jar checksum.
    • Build: DISABLE_BUILD_UI=ON ./build.sh --fe passed, including Checkstyle.
  • Behavior changed:
    • Yes. Necessary inequalities are retained and unsafe expression substitutions are rejected while direct comparison propagation is preserved.
  • Does this need documentation?
    • No.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@feiniaofeiafei

Copy link
Copy Markdown
Collaborator Author

run buildall

@morrySnow morrySnow changed the title [fix](fe) Preserve semantics in predicate inference [fix](rbo) Preserve semantics in predicate inference Sep 14, 2026
@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 16668 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 1acbe050b88ea9687e4594e2d83cd9285a59b1c0, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17654	3033	2999	2999
q2	2068	250	213	213
q3	10280	860	512	512
q4	4668	245	208	208
q5	7675	561	383	383
q6	136	114	92	92
q7	541	495	383	383
q8	9237	860	952	860
q9	3463	2395	2353	2353
q10	6525	849	748	748
q11	397	197	180	180
q12	614	261	202	202
q13	18120	1519	1160	1160
q14	155	157	140	140
q15	q16	433	393	371	371
q17	1373	901	813	813
q18	3086	2232	2238	2232
q19	1133	893	779	779
q20	366	276	197	197
q21	5341	1616	1826	1616
q22	324	264	227	227
Total cold run time: 93589 ms
Total hot run time: 16668 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3392	3336	3319	3319
q2	510	392	370	370
q3	2308	2278	2157	2157
q4	1186	1163	903	903
q5	2184	2098	2088	2088
q6	172	121	86	86
q7	1031	907	868	868
q8	1590	1378	1396	1378
q9	3085	3067	3074	3067
q10	1850	1844	1642	1642
q11	360	262	246	246
q12	449	429	342	342
q13	1474	1542	1150	1150
q14	167	173	161	161
q15	q16	389	396	359	359
q17	3586	3253	3252	3252
q18	4789	4412	4736	4412
q19	898	788	850	788
q20	1047	999	814	814
q21	3831	3087	3349	3087
q22	395	353	307	307
Total cold run time: 34693 ms
Total hot run time: 30796 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 82069 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 1acbe050b88ea9687e4594e2d83cd9285a59b1c0, data reload: false

query5	4262	422	337	337
query6	384	140	120	120
query7	4947	416	235	235
query8	288	125	119	119
query9	8682	2895	2866	2866
query10	392	220	186	186
query11	5389	1018	899	899
query12	120	71	76	71
query13	1184	427	309	309
query14	5938	2203	2070	2070
query14_1	1992	1976	1989	1976
query15	174	119	111	111
query16	914	371	370	370
query17	786	454	360	360
query18	2333	337	249	249
query19	171	148	111	111
query20	90	69	73	69
query21	197	108	94	94
query22	5307	5346	5323	5323
query23	6804	6143	6126	6126
query23_1	6017	6166	6054	6054
query24	7279	1103	776	776
query24_1	783	789	785	785
query25	422	306	257	257
query26	1232	232	128	128
query27	2781	415	254	254
query28	4687	1494	1481	1481
query29	929	439	352	352
query30	258	158	130	130
query31	827	400	334	334
query32	129	77	76	76
query33	459	223	186	186
query34	990	857	493	493
query35	394	398	359	359
query36	559	578	520	520
query37	123	82	100	82
query38	996	840	826	826
query39	506	485	517	485
query39_1	473	473	478	473
query40	196	90	73	73
query41	52	49	49	49
query42	71	71	70	70
query43	239	239	213	213
query44	979	531	540	531
query45	109	107	99	99
query46	785	859	530	530
query47	735	743	704	704
query48	310	320	236	236
query49	540	235	188	188
query50	735	259	199	199
query51	8148	8083	8052	8052
query52	72	68	63	63
query53	193	205	156	156
query54	205	159	151	151
query55	73	57	55	55
query56	224	178	154	154
query57	687	777	613	613
query58	199	184	175	175
query59	1233	1216	1090	1090
query60	228	195	180	180
query61	134	113	106	106
query62	353	198	183	183
query63	167	144	140	140
query64	2804	726	614	614
query65	1623	1586	1547	1547
query66	1922	251	214	214
query67	9926	9701	9715	9701
query68	2988	1203	758	758
query69	340	222	191	191
query70	673	598	609	598
query71	255	173	169	169
query72	2299	1694	1485	1485
query73	623	578	348	348
query74	1990	1231	1143	1143
query75	1178	1095	952	952
query76	2384	712	534	534
query77	257	258	204	204
query78	3934	3530	3192	3192
query79	2345	866	568	568
query80	1604	324	275	275
query81	494	155	132	132
query82	608	129	92	92
query83	323	208	193	193
query84	305	111	86	86
query85	828	391	344	344
query86	392	177	170	170
query87	1015	977	880	880
query88	2777	2101	2109	2101
query89	283	193	175	175
query90	1931	129	118	118
query91	131	115	97	97
query92	81	71	69	69
query93	1399	1169	691	691
query94	613	254	221	221
query95	519	253	235	235
query96	802	562	280	280
query97	1064	1052	1026	1026
query98	178	143	133	133
query99	421	345	307	307
Total cold run time: 177585 ms
Total hot run time: 82069 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 14.7 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 1acbe050b88ea9687e4594e2d83cd9285a59b1c0, data reload: false

query1	0.00	0.01	0.00
query2	0.07	0.03	0.04
query3	0.26	0.11	0.09
query4	1.60	0.09	0.09
query5	0.17	0.16	0.15
query6	1.30	0.71	0.68
query7	0.03	0.01	0.00
query8	0.04	0.02	0.03
query9	0.29	0.23	0.21
query10	0.37	0.34	0.34
query11	0.16	0.12	0.12
query12	0.15	0.12	0.12
query13	0.31	0.32	0.31
query14	0.47	0.44	0.44
query15	0.36	0.35	0.35
query16	0.20	0.22	0.23
query17	0.70	0.70	0.71
query18	0.18	0.17	0.16
query19	1.22	1.21	1.21
query20	0.01	0.01	0.01
query21	15.46	0.17	0.12
query22	5.08	0.04	0.05
query23	16.18	0.26	0.10
query24	2.99	0.30	0.29
query25	0.10	0.05	0.04
query26	0.87	0.16	0.12
query27	0.03	0.03	0.03
query28	3.68	0.56	0.26
query29	12.48	3.11	2.56
query30	0.26	0.10	0.12
query31	2.76	0.37	0.18
query32	3.54	0.32	0.24
query33	1.44	1.37	1.46
query34	15.36	2.24	1.78
query35	1.75	1.71	1.71
query36	0.45	0.28	0.28
query37	0.06	0.04	0.04
query38	0.05	0.03	0.03
query39	0.03	0.02	0.02
query40	0.11	0.07	0.08
query41	0.07	0.03	0.02
query42	0.04	0.02	0.02
query43	0.03	0.03	0.03
Total cold run time: 90.71 s
Total hot run time: 14.7 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 93.33% (14/15) 🎉
Increment coverage report
Complete coverage report

@freemandealer

Copy link
Copy Markdown
Member

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: three P1 predicate-inference correctness gaps remain. Two can turn a successful query into an error or remove valid join rows; the third is a head-only weakening that admits rows from a contradictory filter.

Review status: capped/incomplete. The third and final permitted convergence round produced the head-only graph witness in the third comment. All currently known candidates were independently adjudicated and are included or dismissed, but the contract does not permit another round to establish no-new-finding convergence.

Checkpoint conclusions:

  • Goal/correctness: the patch directionally fixes the reported DATE/signed-zero replacement and QUALIFY retention cases, but it does not fully preserve predicate semantics because of the three inline blockers.
  • Scope/focus: the implementation changes are small and focused on the two inference helpers, with matching unit/regression updates; no user-supplied focus points were present.
  • Concurrency: not applicable. These are per-plan FE rewrite data structures with no new shared state, threads, locks, or atomics.
  • Lifecycle/static initialization: not applicable; no resource ownership, teardown, or static/global initialization changed.
  • Configuration: no configuration items were added or changed.
  • Compatibility: no public symbols, persisted formats, RPC/thrift contracts, or rolling-upgrade behavior changed.
  • Parallel paths: traced PullUpPredicates/InferPredicates through shared PredicateInferUtils cast extraction into both replacement and inequality inference. The shared non-injective temporal pair must be fenced at extraction, while the unrelated set-operation movement concern found during review predates and bypasses this diff.
  • Special conditions: the new type allowlist is explained but omits the NoneMovableFunction contract; the direct-comparison exception assumes injective equality extraction; and the retained-relation update interacts unsafely with the existing bidirectional EQ clear.
  • Test coverage: the added unit tests and production-path regressions cover the reported DATE, signed-zero, strict/non-strict QUALIFY, and order cases. Missing negative coverage is an assert_true join, a lossy TIMESTAMPTZ join, and the overlapping EQ/GT/GTE five-edge filter/permutations from the comments.
  • Test results: the changed golden outputs are consistent with their SQL on static inspection. This review did not run builds or tests because the review contract prohibited them. The author reports an FE build, 65 unit cases, and six regression suites; current GitHub checks show FE UT, P0 Regression, COMPILE, and CheckStyle passing, while check_coverage_fe is failing.
  • Observability: no increased logging or metrics are needed for these deterministic planner rewrites.
  • Transactions/persistence: not applicable; there are no EditLog, failover, or persisted-state changes.
  • Data writes: not applicable; the patch changes optimizer predicates only, not mutation atomicity or storage paths.
  • FE/BE propagation: no new variable or protocol value crosses FE/BE boundaries.
  • Performance: the new type/shape checks are constant-time per candidate and the relation assignment does not materially change the existing graph complexity; no distinct performance blocker was found.
  • Other issues: every candidate is resolved in the ledger. A real pre-existing set-operation NoneMovableFunction movement path and an earlier pre-existing three-edge graph witness were excluded because neither is attributable to a changed line.

Review method: static-only full-diff/control-flow review, existing-thread and raw-comment duplicate fence, three subagent rounds, and an explicit final changed-file/candidate sweep.

keep[i] = true;
set(deduced, left, right, Relation.EQ);
// Preserve the relation of the retained predicate; an inequality is not an equality.
set(deduced, left, right, type);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Preserve strict edges after recording the retained relation

This assignment creates a head-only weakening when equality and strict/non-strict edges overlap. For the ordered filter a = c AND c > a AND c >= b AND b > c AND b = c, selection starts with a=b EQ, a=c EQ, and b>a GT. Here c>=b enters this branch. Recording it as GTE makes the closure treat the later b>c input as redundant; generation then emits a=b and clear(..., EQ) also removes the distinct reverse b>a GT. The result keeps only equalities plus c>=b, so a=b=c passes although the input is contradictory. With the base revision's EQ write, b>c is retained and the contradiction remains. Please preserve simultaneous reverse relations (or make EQ clearing relation-aware) and add this ordered case plus permutations to the semantic oracle and a filter regression.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes (summary-only): the final live duplicate recheck found that exact-head review 5206987890 already raised every distinct blocking issue, so this review intentionally adds no duplicate inline comments. I independently reproduced the two result-correctness roots at comments 4013186177 and 4013186195 and found no additional valuable finding after two convergence rounds.

Checkpoint conclusions:

  • Goal/correctness: the patch fixes the reported consistent QUALIFY chain and tested DATE/signed-zero substitution cases, but it does not fully preserve query semantics. The existing exact-head threads show that a contradictory EQ/strict relation graph can become satisfiable and that a non-injective TIMESTAMPTZ-to-DATETIME equality can infer a false comparison/IN predicate.
  • Scope/focus: the production changes are small and focused on the two inference helpers, with matching unit and regression coverage. No additional user-provided focus was present.
  • Concurrency: not applicable. These are per-plan FE rewrite structures with no new shared state, threads, locks, or atomics.
  • Lifecycle/static initialization: not applicable; no ownership, teardown, static, or global initialization changed.
  • Configuration: no configuration item was added or changed.
  • Compatibility: no public symbol, persisted format, RPC/thrift contract, or rolling-upgrade behavior changed.
  • Parallel paths and rule staging: traced replacement followed by inequality inference through filters, joins (including mark/outer/semi/anti restrictions), window/QUALIFY, set operations, and both repeated InferPredicates/pushdown stages. Those paths make both blocking predicates executable; no separate registration, property, or rewrite-loop issue was found.
  • Special conditions: the new direct-predicate exception requires an injective extracted equality, and the retained-relation update still interacts with one-relation-per-direction storage and symmetric EQ clearing. The existing inline threads give concrete plan trees and fix directions.
  • Test coverage: the new deterministic unit/regression tests cover the advertised relation orders, qualifiers, DATE/DATETIME, decimal scale, signed zero, widening casts, and direct comparison/IN/NOT IN cases. They omit contradictory EQ/strict graphs and non-injective TIMESTAMPTZ casts.
  • Test results: all changed golden outputs match their SQL inputs on static inspection. This review did not run builds or tests because the review contract prohibited them. The author reports an FE build, 65 unit tests, and six regression suites; current GitHub checks show COMPILE, FE UT, P0 Regression, NonConcurrent Regression, and CheckStyle passing, while check_coverage_fe is failing.
  • Observability: no additional logs or metrics are needed for these deterministic planner rewrites.
  • Transactions/persistence and data writes: not applicable; there are no EditLog, failover, atomicity, mutation, or storage-path changes.
  • FE/BE propagation: no new variable or protocol value crosses the FE/BE boundary.
  • Performance: the added type/shape checks are constant-time per replacement candidate, and the relation assignment does not change the existing graph complexity; no material CPU, allocation, or memory issue was found.
  • Other issues/completion: all candidates are resolved. The two substantiated findings are already covered by exact-head inline comments, the other live concern was duplicate-fenced, and the full eight-file final sweep found no third distinct issue. This review is complete and statically verified at head 1acbe050b88ea9687e4594e2d83cd9285a59b1c0.

feiniaofeiafei added a commit to feiniaofeiafei/doris that referenced this pull request Sep 17, 2026
…erence suites

### What problem does this PR solve?

Related PR: apache#67919

Problem Summary: Add a filter regression for equality and reverse strict inequalities, including reordered and commuted comparisons, nullable rows, and a non-strict positive control. Extend the QUALIFY regression with the materialized-window comparison from the original reproduction. Move both suites introduced by the related PR and their expected files into nereids_rules_p0/infer_predicate. Keep all 120 input-order permutations across three qualifier layouts focused on input predicate selection, with reported-order coverage for full inference; separate graph-construction overwrites in full inference are outside this repair.

### Release note

None

### Check List (For Author)

- Test: Regression test / Unit Test / Manual test
    - All 66 tests in UnequalPredicateInferTest and InferPredicateByReplaceTest passed using run-fe-ut.sh.
    - All seven suites passed: infer_predicate_qualify, infer_predicate_reverse_relation, infer_predicate_replace_type, infer_unequal_predicates, extend_infer_equal_predicate, infer_datetimev2_cast_precision, and infer_predicate.
    - New and updated expected files were generated by run-regression-test.sh and verified by rerunning comparisons.
    - DISABLE_BUILD_UI=ON ./build.sh --fe passed on dev, including Checkstyle. The default UI build is blocked by Node.js 16 lacking node:util.styleText.
    - Deployed the built FE library to the requested test cluster, verified the JAR checksum and clear() bytecode, and retained the previous library backup.
    - Final FE Checkstyle passed with zero violations.
- Behavior changed: No. Test coverage and test locations only.
- Does this need documentation: No.
@feiniaofeiafei

Copy link
Copy Markdown
Collaborator Author

run buildall

@feiniaofeiafei

Copy link
Copy Markdown
Collaborator Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes (summary-only): the exact-head duplicate fence already contains the only surviving blocker, so this review intentionally adds no duplicate inline comment. Current head 89d698b217567fbb63810e8b27ace5f1bc51bd01 statically resolves existing comments 4013186177 (lossy TIMESTAMPTZ cast extraction) and 4013186189 (NoneMovableFunction propagation), but the wrong-row failure in 4013186195 remains reproducible at UnequalPredicateInfer.java:452. The one-relation-per-direction matrix can overwrite an opposing strict fact, and later clear(..., EQ) removes the reverse edge, allowing an all-equal row through a contradictory filter.

Checkpoint conclusions:

  • Goal/correctness: the replacement/cast portion now preserves the reviewed type, signed-zero, TIMESTAMPTZ, and non-movable-function semantics. The inequality portion does not fully accomplish the PR goal because the existing overlapping EQ/GT/GTE witness still weakens the input predicate set.
  • Scope/focus: the production changes are small and focused across the two inference helpers and date injectivity metadata, with matching unit/regression additions. There was no additional user-provided focus.
  • Concurrency: not applicable. These are per-plan FE rewrite structures with no new shared state, threads, locks, or atomics.
  • Lifecycle/static initialization: not applicable; no resource ownership, teardown, static initialization, or global initialization changed.
  • Configuration: no configuration item was added or changed.
  • Compatibility: no persisted format, public function symbol, RPC/thrift contract, or rolling-upgrade behavior changed.
  • Parallel paths and staging: traced PullUpPredicates and InferPredicates through shared cast extraction, replacement, inequality inference, filter replacement, sibling join pushdown, window/QUALIFY, aggregate-key simplification, and DISTINCT set-operation pushdown. No separate registration, property, or rewrite-loop issue was found.
  • Special conditions: exact-type arbitrary-expression substitution, NoneMovableFunction rejection, and injective DATE/DATEV2 cast peeling are justified by concrete runtime representations. The remaining unsafe condition is the interaction between retained-relation overwrite and symmetric equality clearing already documented in 4013186195.
  • Test coverage: the new unit and regression cases cover advertised relation orders/qualifiers, DATE/DATETIME representation, signed zero, direct comparison/IN/NOT IN, non-movable assertions, and lossy TIMESTAMPTZ joins. The inequality oracle does not cover overlapping relations on the same directed pair, which is the existing blocker's required negative case.
  • Test results: all 16 changed files and every new golden row were checked statically and are internally consistent. This review did not run builds or tests because the review contract prohibits them; it does not independently validate the author's reported executions.
  • Observability: no new logs or metrics are needed for these deterministic planner rewrites.
  • Transactions/persistence and data writes: not applicable; there are no EditLog, failover, mutation atomicity, or storage-path changes.
  • FE/BE propagation: no new variable or protocol value crosses the FE/BE boundary.
  • Performance: the added predicate-tree scans and type checks are bounded by existing inference inputs and do not change graph complexity; no material CPU, allocation, or memory concern was found.
  • Other issues/completion: all candidates are resolved. Two normal full-review scopes plus a separate risk-focused scope returned NO_NEW_VALUABLE_FINDINGS in Round 1; larger graph sweeps reproduced only the existing 4013186195 root. The review is complete, duplicate-safe, and static-only at the stated head.

Please resolve the existing line-452 P1 and add its overlapping-edge permutation/regression coverage before merge.

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 27570 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 89d698b217567fbb63810e8b27ace5f1bc51bd01, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17619	3894	3838	3838
q2	2318	329	286	286
q3	10002	1452	828	828
q4	4688	477	362	362
q5	7488	818	530	530
q6	174	166	135	135
q7	741	790	599	599
q8	9345	1484	1567	1484
q9	6242	4211	4166	4166
q10	6801	1635	1372	1372
q11	447	269	246	246
q12	638	409	294	294
q13	18070	2619	2027	2027
q14	275	267	238	238
q15	q16	740	717	664	664
q17	1706	1153	1050	1050
q18	6438	5600	5540	5540
q19	1172	1320	1033	1033
q20	488	398	271	271
q21	5615	2602	2314	2314
q22	424	348	293	293
Total cold run time: 101431 ms
Total hot run time: 27570 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4135	4071	4037	4037
q2	777	599	583	583
q3	4493	4906	4304	4304
q4	2252	2323	1438	1438
q5	4214	4079	4072	4072
q6	224	178	131	131
q7	1656	1591	1435	1435
q8	2160	2479	2139	2139
q9	7502	7468	7700	7468
q10	4361	4354	3891	3891
q11	561	396	378	378
q12	720	738	521	521
q13	2659	2827	2170	2170
q14	282	299	270	270
q15	q16	685	726	642	642
q17	7704	7179	7145	7145
q18	11932	11099	11873	11099
q19	1206	1055	1050	1050
q20	2226	2267	1969	1969
q21	5834	4787	4836	4787
q22	558	492	432	432
Total cold run time: 66141 ms
Total hot run time: 59961 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 154208 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 89d698b217567fbb63810e8b27ace5f1bc51bd01, data reload: false

query5	4320	619	480	480
query6	458	197	179	179
query7	4833	533	299	299
query8	327	181	189	181
query9	8802	4054	4006	4006
query10	457	319	254	254
query11	5837	2231	2020	2020
query12	153	98	95	95
query13	1247	592	383	383
query14	6500	4688	4285	4285
query14_1	4133	4085	4049	4049
query15	203	192	175	175
query16	1013	445	400	400
query17	885	649	533	533
query18	2432	473	335	335
query19	202	179	138	138
query20	107	106	104	104
query21	252	143	120	120
query22	13095	13012	12834	12834
query23	15560	14551	13934	13934
query23_1	14146	14176	14111	14111
query24	7798	1710	1227	1227
query24_1	1245	1241	1251	1241
query25	548	415	371	371
query26	1264	317	161	161
query27	2718	546	331	331
query28	4611	1960	1959	1959
query29	1044	595	475	475
query30	333	240	201	201
query31	888	772	635	635
query32	206	104	95	95
query33	539	317	253	253
query34	1226	1133	635	635
query35	747	766	662	662
query36	792	816	733	733
query37	173	118	97	97
query38	1890	1788	1742	1742
query39	722	691	685	685
query39_1	648	658	643	643
query40	232	126	107	107
query41	73	71	72	71
query42	93	98	92	92
query43	363	362	320	320
query44	1360	682	701	682
query45	191	179	171	171
query46	1030	1171	729	729
query47	1493	1473	1399	1399
query48	407	422	280	280
query49	612	412	313	313
query50	927	344	248	248
query51	10655	10619	10403	10403
query52	96	93	77	77
query53	252	264	197	197
query54	278	219	203	203
query55	88	75	70	70
query56	259	233	238	233
query57	1500	1442	1285	1285
query58	259	224	207	207
query59	1968	2073	1840	1840
query60	317	259	230	230
query61	166	157	189	157
query62	406	322	277	277
query63	222	182	187	182
query64	2944	989	807	807
query65	4054	4004	3972	3972
query66	1861	421	302	302
query67	20234	20163	19951	19951
query68	3216	1542	948	948
query69	408	296	255	255
query70	972	907	888	888
query71	309	221	215	215
query72	2877	2497	2185	2185
query73	826	731	435	435
query74	4670	4487	4298	4298
query75	2305	2294	1932	1932
query76	2370	1105	719	719
query77	367	400	301	301
query78	9176	9046	8508	8508
query79	1352	1162	742	742
query80	690	444	376	376
query81	500	291	246	246
query82	1096	176	130	130
query83	324	286	251	251
query84	319	143	115	115
query85	919	465	432	432
query86	331	230	223	223
query87	2020	1987	1846	1846
query88	3664	2750	2696	2696
query89	367	285	248	248
query90	1850	181	180	180
query91	172	152	123	123
query92	103	92	92	92
query93	1524	1424	819	819
query94	578	351	312	312
query95	673	366	355	355
query96	1053	753	330	330
query97	2439	2489	2307	2307
query98	207	186	182	182
query99	730	716	617	617
Total cold run time: 243239 ms
Total hot run time: 154208 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.06 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 89d698b217567fbb63810e8b27ace5f1bc51bd01, data reload: false

query1	0.00	0.00	0.00
query2	0.10	0.05	0.05
query3	0.26	0.14	0.13
query4	1.61	0.14	0.13
query5	0.25	0.23	0.23
query6	1.16	0.96	0.93
query7	0.04	0.00	0.01
query8	0.06	0.04	0.04
query9	0.41	0.35	0.35
query10	0.59	0.58	0.56
query11	0.20	0.14	0.14
query12	0.18	0.15	0.16
query13	0.47	0.46	0.48
query14	0.96	0.94	0.95
query15	0.63	0.60	0.59
query16	0.34	0.34	0.32
query17	1.09	1.12	1.09
query18	0.24	0.21	0.20
query19	2.00	1.99	1.90
query20	0.02	0.02	0.01
query21	15.46	0.23	0.13
query22	4.76	0.05	0.05
query23	16.09	0.32	0.12
query24	3.05	0.46	0.35
query25	0.12	0.06	0.04
query26	0.75	0.20	0.14
query27	0.04	0.04	0.03
query28	3.51	0.77	0.37
query29	12.50	4.09	3.25
query30	0.30	0.16	0.16
query31	2.77	0.57	0.31
query32	3.22	0.60	0.49
query33	3.19	3.11	3.20
query34	15.55	3.92	3.29
query35	3.20	3.23	3.23
query36	0.57	0.43	0.42
query37	0.08	0.06	0.06
query38	0.05	0.04	0.03
query39	0.04	0.03	0.04
query40	0.18	0.15	0.14
query41	0.08	0.03	0.03
query42	0.04	0.03	0.03
query43	0.05	0.03	0.03
Total cold run time: 96.21 s
Total hot run time: 24.06 s

feiniaofeiafei added a commit to feiniaofeiafei/doris that referenced this pull request Sep 18, 2026
### What problem does this PR solve?

Related PR: apache#67919

Problem Summary: Clearing a selected equality also removes the reverse graph entry even when that entry holds an independent inequality. For the ordered filter a = c AND c > a AND c >= b AND b > c AND b = c, inference can first discard strict input predicates as redundant and then erase their remaining strict constraint while emitting an equality. Equal-valued rows consequently pass a contradictory filter. Clear the reverse entry only when it also represents equality. Add semantic checks for the reported order and all 120 permutations across three qualifier layouts, covering both predicate inference entry points.

### Release note

Fix incorrect rows returned when predicate inference removes reverse inequalities while emitting equalities.

### Check List (For Author)

- Test: Unit Test / Manual test
    - The new semantic test reproduces the failure before the fix: 26 tests run, one failure, with a = b = c = 0 incorrectly passing.
    - FE Checkstyle passed with zero violations.
    - Post-fix unit tests and cluster regression validation will follow on the dev build host.
- Behavior changed: Yes. Reverse inequality constraints are retained when clearing an equality.
- Does this need documentation: No.
feiniaofeiafei added a commit to feiniaofeiafei/doris that referenced this pull request Sep 18, 2026
### What problem does this PR solve?

Related PR: apache#67919

Problem Summary: Add a filter regression for a = c AND c > a AND c >= b AND b > c AND b = c. Include reversed predicate order, commuted comparisons, null inputs, and a satisfiable non-strict control to ensure inference preserves contradictions without discarding valid equal-valued rows.

### Release note

None

### Check List (For Author)

- Test: Regression validation and runner-generated expectations pending on dev
- Behavior changed: No, tests only
- Does this need documentation: No
feiniaofeiafei added a commit to feiniaofeiafei/doris that referenced this pull request Sep 18, 2026
### What problem does this PR solve?

Related PR: apache#67919

Problem Summary: Record the regression-runner output for contradictory filters containing overlapping equalities and strict reverse relations. Original, reversed, and commuted forms must return no rows, while the non-strict control keeps both equal non-null rows. Before the fix, the original and commuted forms each incorrectly returned two rows.

### Release note

None

### Check List (For Author)

- Test: Regression test: generated the new .out with run-regression-test.sh and reran all nine related suites successfully. FE build and Checkstyle passed. Manual before/after verification confirmed the incorrect rows are removed.
- Behavior changed: No, test expectations only
- Does this need documentation: No
feiniaofeiafei added a commit to feiniaofeiafei/doris that referenced this pull request Sep 18, 2026
### What problem does this PR solve?

Related PR: apache#67919

Problem Summary: inferUnequalPredicates replaces predicates and must preserve full filter equivalence across all 120 input orders. inferAllPredicates supplies implied facts for redundant-predicate suppression rather than replacing the original filter; it need not return an equivalent contradictory filter for every order. Keep the reported-order coverage for both entry points and the full permutation oracle for replacement inference.

### Release note

None

### Check List (For Author)

- Test: The initial FE unit run identified the overly broad inferAllPredicates assertion. Replacement inference passed all tested permutations; full rerun pending. Nine regression suites passed.
- Behavior changed: No, test assertion scope only
- Does this need documentation: No
@feiniaofeiafei

Copy link
Copy Markdown
Collaborator Author

run buildall

@feiniaofeiafei

Copy link
Copy Markdown
Collaborator Author

/review

@feiniaofeiafei
feiniaofeiafei force-pushed the codex/fix-predicate-inference-semantics branch from f2fa306 to d0fef8d Compare September 18, 2026 02:33
@feiniaofeiafei

Copy link
Copy Markdown
Collaborator Author

run buildall

@feiniaofeiafei

Copy link
Copy Markdown
Collaborator Author

/review

### What problem does this PR solve?

Related PR: apache#67919

Problem Summary: Record the regression-runner output for contradictory filters containing overlapping equalities and strict reverse relations. Original, reversed, and commuted forms must return no rows, while the non-strict control keeps both equal non-null rows. Before the fix, the original and commuted forms each incorrectly returned two rows.

### Release note

None

### Check List (For Author)

- Test: Regression test: generated the new .out with run-regression-test.sh and reran all nine related suites successfully. FE build and Checkstyle passed. Manual before/after verification confirmed the incorrect rows are removed.
- Behavior changed: No, test expectations only
- Does this need documentation: No
@feiniaofeiafei
feiniaofeiafei force-pushed the codex/fix-predicate-inference-semantics branch from 6b9d127 to 84e061d Compare September 20, 2026 08:24
@feiniaofeiafei

Copy link
Copy Markdown
Collaborator Author

run buildall

@feiniaofeiafei

Copy link
Copy Markdown
Collaborator Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: four distinct P1 evaluation-domain gaps remain at exact head 84e061d80a2727f9b49eec749bfdb1b768a1addf. The new NoneMovableFunction marker is honored by the changed predicate paths, but eager aggregation and several Limit/TopN project rewrites still add or suppress evaluation of to_bitmap_with_check on rows outside its original domain.

Checkpoint conclusions:

  • Goal/correctness: the replacement allowlist, injective-cast recursion, inequality relation retention, and changed movement fences are sound on static inspection. The four inline paths remain observable because invalid bitmap conversion returns InvalidArgument.
  • Scope and parallel paths: all 31 authoritative changed files and the relevant inference, eager-aggregation, Limit/TopN, join, aggregate, set-operation, CTE, CASE, and project-pruning paths were covered. Existing inline threads were hard duplicate fences.
  • Rule ordering/configuration: the witnesses survive the exact rewrite schedule. Forced eager_aggregation_mode=1 reaches the eager path; push_topn_to_agg is enabled by default; the Project/Limit and TopN/join transposes have no later inverse that restores the original evaluation domain.
  • Tests/results: the added unit and regression oracles are internally consistent for the changed inference fixes, but do not cover these four movement families. This review was static-only as required; no build or repository test was run. Current GitHub evidence shows COMPILE, CheckStyle, and several lightweight checks passing, while FE UT, regression, performance, and other jobs remain pending; those are not independent validation by this review.
  • Concurrency, lifecycle, configuration changes, compatibility, persistence/transactions, data writes, FE-BE protocol propagation, and observability: not otherwise implicated by these statement-local planner changes.
  • Performance: no separate material performance defect survived review; the issue is observable error semantics, not planner complexity.
  • Completion: two bounded rounds completed. The final full-diff, movement-focused, and inference-focused passes all returned NO_NEW_VALUABLE_FINDINGS; every candidate is accepted, dismissed with evidence, or duplicate-fenced.

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 27953 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 84e061d80a2727f9b49eec749bfdb1b768a1addf, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17672	3851	3818	3818
q2	2189	378	302	302
q3	10038	1399	775	775
q4	4680	485	354	354
q5	7527	881	543	543
q6	176	164	132	132
q7	758	789	615	615
q8	9314	1558	1500	1500
q9	5456	4220	4173	4173
q10	6828	1322	1013	1013
q11	436	265	242	242
q12	637	418	302	302
q13	18025	2622	2037	2037
q14	275	265	242	242
q15	q16	736	718	657	657
q17	1689	1138	1037	1037
q18	6480	5571	5560	5560
q19	1185	1286	1000	1000
q20	474	376	262	262
q21	5293	3150	3077	3077
q22	443	380	312	312
Total cold run time: 100311 ms
Total hot run time: 27953 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5074	4806	4438	4438
q2	743	574	549	549
q3	4780	5176	4524	4524
q4	2280	2374	1475	1475
q5	4537	4400	4509	4400
q6	229	177	126	126
q7	1840	1663	1504	1504
q8	2320	2118	2068	2068
q9	7366	7290	7198	7198
q10	3704	3676	3134	3134
q11	553	388	357	357
q12	702	705	504	504
q13	2268	2614	1990	1990
q14	276	272	244	244
q15	q16	660	682	624	624
q17	7246	6733	6695	6695
q18	11941	11072	11768	11072
q19	1094	1003	988	988
q20	2200	2183	1890	1890
q21	4992	4238	4364	4238
q22	529	450	389	389
Total cold run time: 65334 ms
Total hot run time: 58407 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 151744 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 84e061d80a2727f9b49eec749bfdb1b768a1addf, data reload: false

query5	4315	598	448	448
query6	414	203	196	196
query7	4796	527	278	278
query8	323	178	166	166
query9	8834	4036	4040	4036
query10	451	313	260	260
query11	5885	3557	3234	3234
query12	149	93	88	88
query13	1284	577	408	408
query14	6569	4520	4236	4236
query14_1	3989	3975	3978	3975
query15	203	199	179	179
query16	992	487	456	456
query17	932	690	562	562
query18	2439	483	336	336
query19	204	183	146	146
query20	83	80	86	80
query21	222	134	118	118
query22	13039	13058	12858	12858
query23	14101	13118	12520	12520
query23_1	12643	12538	12720	12538
query24	7292	1208	680	680
query24_1	727	657	680	657
query25	569	443	374	374
query26	1256	314	163	163
query27	2743	589	341	341
query28	4552	1981	1961	1961
query29	1631	730	539	539
query30	307	222	184	184
query31	898	758	640	640
query32	148	97	102	97
query33	532	328	259	259
query34	1211	1087	635	635
query35	724	754	634	634
query36	782	844	718	718
query37	153	107	96	96
query38	1828	1763	1717	1717
query39	701	691	665	665
query39_1	669	664	668	664
query40	223	126	107	107
query41	71	68	72	68
query42	101	99	97	97
query43	336	343	304	304
query44	1397	725	728	725
query45	188	179	167	167
query46	1080	1198	741	741
query47	1495	1510	1386	1386
query48	452	421	296	296
query49	590	400	303	303
query50	963	356	255	255
query51	10395	10439	10174	10174
query52	87	88	73	73
query53	243	252	180	180
query54	258	198	180	180
query55	78	75	78	75
query56	237	220	230	220
query57	1349	1378	1351	1351
query58	278	264	268	264
query59	1980	2046	1827	1827
query60	284	236	220	220
query61	150	149	151	149
query62	401	321	269	269
query63	218	175	181	175
query64	2807	988	791	791
query65	3505	3420	3416	3416
query66	1795	442	300	300
query67	19997	20285	19833	19833
query68	3345	1389	805	805
query69	415	295	256	256
query70	887	823	792	792
query71	295	235	213	213
query72	2610	2481	1740	1740
query73	796	764	422	422
query74	4619	4476	4273	4273
query75	2282	2313	1931	1931
query76	2320	1127	680	680
query77	367	386	299	299
query78	9279	9092	8513	8513
query79	1349	1224	760	760
query80	568	443	376	376
query81	542	321	275	275
query82	612	171	124	124
query83	311	217	192	192
query84	317	149	114	114
query85	842	452	384	384
query86	326	234	231	231
query87	1959	1984	1813	1813
query88	3581	2696	2687	2687
query89	355	290	245	245
query90	1927	179	175	175
query91	169	156	126	126
query92	104	90	87	87
query93	1444	1481	805	805
query94	529	319	295	295
query95	684	374	342	342
query96	1027	780	339	339
query97	2444	2445	2320	2320
query98	158	147	145	145
query99	726	728	617	617
Total cold run time: 236302 ms
Total hot run time: 151744 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.14 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 84e061d80a2727f9b49eec749bfdb1b768a1addf, data reload: false

query1	0.01	0.01	0.00
query2	0.09	0.05	0.05
query3	0.26	0.13	0.13
query4	1.61	0.13	0.14
query5	0.24	0.22	0.22
query6	1.16	0.94	0.91
query7	0.04	0.01	0.00
query8	0.06	0.04	0.04
query9	0.40	0.33	0.36
query10	0.55	0.54	0.55
query11	0.19	0.14	0.15
query12	0.19	0.14	0.15
query13	0.47	0.48	0.47
query14	0.95	0.94	0.93
query15	0.61	0.58	0.58
query16	0.30	0.30	0.32
query17	1.09	1.08	1.09
query18	0.22	0.19	0.20
query19	2.03	1.95	1.93
query20	0.02	0.02	0.01
query21	15.41	0.22	0.15
query22	4.88	0.06	0.05
query23	16.12	0.30	0.12
query24	3.05	0.41	0.33
query25	0.10	0.05	0.06
query26	0.72	0.20	0.14
query27	0.05	0.03	0.04
query28	3.56	0.78	0.34
query29	12.52	4.28	3.43
query30	0.28	0.15	0.16
query31	2.78	0.57	0.31
query32	3.21	0.59	0.48
query33	3.24	3.26	3.18
query34	15.63	3.92	3.28
query35	3.20	3.25	3.22
query36	0.55	0.41	0.42
query37	0.09	0.07	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.02
query40	0.17	0.16	0.14
query41	0.09	0.04	0.03
query42	0.04	0.03	0.03
query43	0.05	0.04	0.03
Total cold run time: 96.32 s
Total hot run time: 24.14 s

@feiniaofeiafei

Copy link
Copy Markdown
Collaborator Author

run feut

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 72.50% (29/40) 🎉
Increment coverage report
Complete coverage report

@yujun777 yujun777 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review confidence: 8/10 that these are real correctness defects. They are not expected to affect every query, but each can change a successful query into an InvalidArgument error or suppress an error by changing the expression evaluation domain. The four paths below should be covered before merge.

@yujun777 yujun777 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@morrySnow
morrySnow merged commit 5f107ef into apache:master Sep 23, 2026
62 of 63 checks passed
@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Sep 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants